package com.hzqy.service.system;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;

import com.hzqy.commons.utils.JsonUtils;
import com.hzqy.persistence.dao.system.SysConfigDao;
import com.hzqy.service.core.GenericServiceBean;
import com.hzqy.web.vo.CmContentVo;
import com.hzqy.web.vo.CmPicturesVo;
import com.hzqy.web.vo.system.SysConfigVo;
@Service
public class SysConfigServiceBeen extends GenericServiceBean<SysConfigVo, SysConfigDao, Integer>{
	private static final long serialVersionUID = 1L;
	protected final Logger LOG = LoggerFactory.getLogger(getClass());
	@Resource
	private SysConfigDao sysConfigDao;

	@Override
	public SysConfigDao getEntityDao(){
		return sysConfigDao;
	}
	public Map<String,Object> selectSysConfigVoList(SysConfigVo sysConfigVo, int curPage,
			int pageSize) {
		Map<String,Object> map = new HashMap<String, Object>();
		Integer rowCount = sysConfigDao.findSysConfigVoListCount(sysConfigVo);
		map.put("total", rowCount);
		if(rowCount > 0 && curPage > 0 && pageSize > 0) {
			map.put("firstResult", (curPage-1)*pageSize);
			map.put("maxResults", pageSize);
			map.put("f_sc_id", sysConfigVo.getF_sc_id());
			map.put("f_sc_key", sysConfigVo.getF_sc_key());
			map.put("f_sc_value", sysConfigVo.getF_sc_value());
			map.put("f_sc_status", sysConfigVo.getF_sc_status());
			List<SysConfigVo> results = sysConfigDao.findSysConfigVoList(map);
			
			map.put("rows", results);
		} else {
			map.put("rows", new ArrayList<SysConfigVo>());
		}
		return map;
	}
	/**
	 * 
	 * 通过Id删除
	 * @param f_sc_id
	 * @return
	 */
	public int deleteSystem(int f_sc_id) {

		return sysConfigDao.deleteSystem(f_sc_id);
	}
	
	
	public int insertSystem(SysConfigVo sysConfigVo) {
		return sysConfigDao.insertSystem(sysConfigVo);
		
	}
	
	public int updateSystem(SysConfigVo sysConfigVo) {
		
		return sysConfigDao.updateSystem(sysConfigVo);		
		
	}
	public SysConfigVo selectSystem(int f_sc_id) {
		return sysConfigDao.selectSystem(f_sc_id);
	}
	
	public SysConfigVo selectSystemByKey(String f_sc_key) {
		return sysConfigDao.selectSystemByKey(f_sc_key);
	}
	
	
}
